<?php
define( '_VALID_MOS', 1 );
require( '../globals.php' );
require( '../configuration.php' );
require_once( '../includes/joomla.php' );
require_once( '../includes/sef.php' );
require_once( '../language/english.php' );
?>
<!-- Tooltips -->
<script type="text/javascript" src="<?php echo $mosConfig_live_site;?>/templates/html_ngayhomnay/js/main.js"></script>
<link href="<?php echo $mosConfig_live_site; ?>/templates/html_ngayhomnay/css/tipTip.css" rel="stylesheet" type="text/css" />
<!-- End Tooltips -->
<?php
$task 	= mosGetParam($_REQUEST, 'task', '');
$id		= intval(mosGetParam($_REQUEST, 'id', 0)); 

$path = $mosConfig_live_site."/uploads/content";
if ($task == 'blogsection'){
	$sql = "SELECT title FROM #__sections WHERE id=".$id;
	$where = " AND sectionid=".$id;
}	
if ($task == 'blogcategory'){
	$sql = "SELECT title FROM #__categories WHERE id=".$id;
	
	$sql = "select * from #__categories where parent_id=".$id;
	$database->setQuery($sql);
	$lsRows = $database->loadObjectList();
	if (count($lsRows)>0){
		$arr = "(".$id.",";
		for ($i=0; $i<count($lsRows); $i++){
			if ($i==(count($lsRows)-1)){
				$str = "";
			}else{
				$str = ",";
			}
			$arr .= $lsRows[$i]->id.$str;
		}
		$arr .= ")";
		//echo $arr;
		$where = " AND catid IN".$arr;
	}else{
		$where = " AND catid=".$id;
	}
}
//show VIP
$sql = "SELECT id,title,title_alias,thumbnailImage,mediumImage,largeImage,price,price_giam,giam_gia,muc_giam,introtext"
		."\n FROM #__content"
		."\n WHERE state=1 AND vip=1".$where." ORDER BY ordering ASC, id DESC LIMIT 9,8";
$database->setQuery( $sql );
$lsVip = $database->loadObjectlist();
for ($i=0; $i<count($lsVip); $i++){
	$linkurl = sefRelToAbs("index.php?option=com_content&task=view&id=".$lsVip[$i]->id).$lsVip[$i]->title_alias;
	?>
	<div class="w_lsProduct style-product-css3">
		<a href="<?php echo $linkurl;?>">
			<?php if ($lsVip[$i]->muc_giam == 0){?>
			<img src="<?php echo $path;?>/medium/<?php echo $lsVip[$i]->mediumImage;?>" border="0" />
			<?php }else{?>
			<img src="<?php echo $path;?>/thumbnail/<?php echo $lsVip[$i]->thumbnailImage;?>" style="width:70px;" border="0" />
			<?php }?>
		</a>
		<div class="clearfix"></div>
		<a href="<?php echo $linkurl;?>"><?php echo $lsVip[$i]->title;?></a><br />
		<?php if ($lsVip[$i]->giam_gia == 0){?>
		<span><?php echo number_format($lsVip[$i]->price,0,".",",");?> VNĐ</span>
		<?php }else{?>
		<span style="font-size:11px;">Giá bán: <?php echo number_format($lsVip[$i]->price_giam,0,".",",");?> VNĐ</span>
		<div class="clearfix"></div>
		<span style="font-size:11px; text-decoration: line-through; color:#707070;">Giá cũ: <?php echo number_format($lsVip[$i]->price,0,".",",");?> VNĐ</span>
		<?php }?>
		<?php if ($lsVip[$i]->muc_giam > 0){?>
		<div class="muc_giam">Giảm: <?php echo number_format($lsVip[$i]->muc_giam,0,".",",");?> VNĐ</div>
		<?php }?>
	</div>
	<?php	
} 
?>